<template>
  <div>
    <el-table :data="histList" style="width: 100%">
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column prop="url" label="访问地址">
        <template #default="scope">
          <div style="width: 100%; height: 20px; overflow: hidden; text-overflow:ellipsis;" :title="scope.row.url">
            <a :href="scope.row.url" target="_blank" v-html="scope.row.url"></a>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="time" label="访问时间" width="160">
        <template #default="scope">
          {{ formatTime(scope.row.time) }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import HistoryService from "@/service/HistoryService"
import TimeUtils from "@/utils/TimeUtils"
export default {
  name: 'History',
  data () {
    return {
      histList: []
    }
  },
  methods: {
    loadHistory() {
      HistoryService.getHistory(histList => {
        console.log('get history:', histList)
        this.histList = histList
      })
    },
    formatTime(mills) {
      return TimeUtils.millisecondToDateTimeStr(mills)
    }
  },
  mounted() {
    this.loadHistory()
  }
}
</script>

<style scoped>

</style>